nanopyx.core.io.unique_names
1# a list of ludicrous dog names to be used as unique identifiers 2# lets see how much time it takes until someone finds this 3 4import random 5 6names = [ 7 "Poodlef", 8 "Schnoodlepuff", 9 "Muttley", 10 "Furball", 11 "Poodlefroot", 12 "Hotdog", 13 "Barkalicious", 14 "Pupperoni", 15 "Doggydoo", 16 "Puppycinno", 17 "Poodlepops", 18 "Barkers", 19 "Muttleydoo", 20 "Poodlepup", 21 "Pupcake", 22 "Barkleberry", 23 "Fluffernutter", 24 "Puppykins", 25 "Poodleberry", 26 "Pupperpuff", 27 "Poodlepop", 28 "Barktastic", 29 "Fluffy_McFluffernutter", 30 "Sir_Barksalot", 31 "Lady_Woofington", 32 "Barkley_von_Wagner", 33 "Count_Fluffernutter", 34 "Duke_of_Woofington", 35 "Baroness_Snugglesnout", 36 "Sir_Wigglesworth", 37 "Lady_Pawsington", 38 "Biscuit_McFluffernutter", 39 "Princess_Fluffybutt" 40] 41 42def intToRoman(num): 43 44 # Storing roman values of digits from 0-9 45 # when placed at different places 46 m = ["", "M", "MM", "MMM"] 47 c = ["", "C", "CC", "CCC", "CD", "D", 48 "DC", "DCC", "DCCC", "CM "] 49 x = ["", "X", "XX", "XXX", "XL", "L", 50 "LX", "LXX", "LXXX", "XC"] 51 i = ["", "I", "II", "III", "IV", "V", 52 "VI", "VII", "VIII", "IX"] 53 54 # Converting to roman 55 thousands = m[num // 1000] 56 hundreds = c[(num % 1000) // 100] 57 tens = x[(num % 100) // 10] 58 ones = i[num % 10] 59 60 ans = (thousands + hundreds + 61 tens + ones) 62 63 return ans 64 65_already_used = [] 66 67def get_unique_name() -> str: 68 """ 69 Get a unique name from the list of names. 70 71 >>> name = get_unique_name() 72 """ 73 # get a unique name 74 global _already_used 75 name = random.choice(names)+"_"+str(intToRoman(random.randint(1, 10))) 76 while name in _already_used: 77 name = random.choice(names)+"_"+str(intToRoman(random.randint(1, 10))) 78 _already_used.append(name) 79 return name
names =
['Poodlef', 'Schnoodlepuff', 'Muttley', 'Furball', 'Poodlefroot', 'Hotdog', 'Barkalicious', 'Pupperoni', 'Doggydoo', 'Puppycinno', 'Poodlepops', 'Barkers', 'Muttleydoo', 'Poodlepup', 'Pupcake', 'Barkleberry', 'Fluffernutter', 'Puppykins', 'Poodleberry', 'Pupperpuff', 'Poodlepop', 'Barktastic', 'Fluffy_McFluffernutter', 'Sir_Barksalot', 'Lady_Woofington', 'Barkley_von_Wagner', 'Count_Fluffernutter', 'Duke_of_Woofington', 'Baroness_Snugglesnout', 'Sir_Wigglesworth', 'Lady_Pawsington', 'Biscuit_McFluffernutter', 'Princess_Fluffybutt']
def
intToRoman(num):
43def intToRoman(num): 44 45 # Storing roman values of digits from 0-9 46 # when placed at different places 47 m = ["", "M", "MM", "MMM"] 48 c = ["", "C", "CC", "CCC", "CD", "D", 49 "DC", "DCC", "DCCC", "CM "] 50 x = ["", "X", "XX", "XXX", "XL", "L", 51 "LX", "LXX", "LXXX", "XC"] 52 i = ["", "I", "II", "III", "IV", "V", 53 "VI", "VII", "VIII", "IX"] 54 55 # Converting to roman 56 thousands = m[num // 1000] 57 hundreds = c[(num % 1000) // 100] 58 tens = x[(num % 100) // 10] 59 ones = i[num % 10] 60 61 ans = (thousands + hundreds + 62 tens + ones) 63 64 return ans
def
get_unique_name() -> str:
68def get_unique_name() -> str: 69 """ 70 Get a unique name from the list of names. 71 72 >>> name = get_unique_name() 73 """ 74 # get a unique name 75 global _already_used 76 name = random.choice(names)+"_"+str(intToRoman(random.randint(1, 10))) 77 while name in _already_used: 78 name = random.choice(names)+"_"+str(intToRoman(random.randint(1, 10))) 79 _already_used.append(name) 80 return name
Get a unique name from the list of names.
>>> name = get_unique_name()